package server

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

/*封装返回的数据*/

/*自定义返回code、data、 msg*/
func result(ctx *gin.Context,code int,data interface{},msg string){
	ctx.JSON(http.StatusOK,gin.H{"code":code,"data": data,"msg":msg})
}
/*自定义返回data 、msg  常用*/
func resultOk(ctx * gin.Context,data interface{}){
	ctx.JSON(http.StatusOK, gin.H{"code": http.StatusOK, "data": data, "msg": ""})
}
func resultOkMsg(ctx * gin.Context,data interface{},msg string){
	ctx.JSON(http.StatusOK, gin.H{"code": http.StatusOK, "data": data, "msg": msg})
}
func resultFail(ctx * gin.Context,msg string){
	ctx.JSON(http.StatusOK, gin.H{"code": http.StatusBadRequest, "data":nil, "msg":msg})
}